{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>日期</th>\n",
       "      <th>名称</th>\n",
       "      <th>类别</th>\n",
       "      <th>单价</th>\n",
       "      <th>数量</th>\n",
       "      <th>金额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2018-07-01</td>\n",
       "      <td>商品A</td>\n",
       "      <td>服装</td>\n",
       "      <td>20</td>\n",
       "      <td>2</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2018-07-02</td>\n",
       "      <td>商品B</td>\n",
       "      <td>服装</td>\n",
       "      <td>200</td>\n",
       "      <td>3</td>\n",
       "      <td>600</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2018-07-03</td>\n",
       "      <td>商品C</td>\n",
       "      <td>食品</td>\n",
       "      <td>1200</td>\n",
       "      <td>4</td>\n",
       "      <td>4800</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2018-07-04</td>\n",
       "      <td>商品A</td>\n",
       "      <td>服装</td>\n",
       "      <td>22</td>\n",
       "      <td>5</td>\n",
       "      <td>110</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2018-07-05</td>\n",
       "      <td>商品B</td>\n",
       "      <td>服装</td>\n",
       "      <td>220</td>\n",
       "      <td>6</td>\n",
       "      <td>1320</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2018-07-06</td>\n",
       "      <td>商品C</td>\n",
       "      <td>食品</td>\n",
       "      <td>1000</td>\n",
       "      <td>7</td>\n",
       "      <td>7000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2018-07-07</td>\n",
       "      <td>商品A</td>\n",
       "      <td>服装</td>\n",
       "      <td>30</td>\n",
       "      <td>3</td>\n",
       "      <td>90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2018-07-08</td>\n",
       "      <td>商品A</td>\n",
       "      <td>服装</td>\n",
       "      <td>800</td>\n",
       "      <td>1</td>\n",
       "      <td>800</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>2018-07-09</td>\n",
       "      <td>商品C</td>\n",
       "      <td>食品</td>\n",
       "      <td>1300</td>\n",
       "      <td>4</td>\n",
       "      <td>5200</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2018-07-10</td>\n",
       "      <td>商品B</td>\n",
       "      <td>服装</td>\n",
       "      <td>230</td>\n",
       "      <td>3</td>\n",
       "      <td>690</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>2018-07-11</td>\n",
       "      <td>商品A</td>\n",
       "      <td>服装</td>\n",
       "      <td>28</td>\n",
       "      <td>1</td>\n",
       "      <td>28</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           日期   名称  类别    单价  数量    金额\n",
       "0  2018-07-01  商品A  服装    20   2    40\n",
       "1  2018-07-02  商品B  服装   200   3   600\n",
       "2  2018-07-03  商品C  食品  1200   4  4800\n",
       "3  2018-07-04  商品A  服装    22   5   110\n",
       "4  2018-07-05  商品B  服装   220   6  1320\n",
       "5  2018-07-06  商品C  食品  1000   7  7000\n",
       "6  2018-07-07  商品A  服装    30   3    90\n",
       "7  2018-07-08  商品A  服装   800   1   800\n",
       "8  2018-07-09  商品C  食品  1300   4  5200\n",
       "9  2018-07-10  商品B  服装   230   3   690\n",
       "10 2018-07-11  商品A  服装    28   1    28"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.read_excel('./loadLec/data.xlsx')\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<pandas.core.groupby.generic.DataFrameGroupBy object at 0x7ff338499d00>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grouped = df.groupby('类别')\n",
    "grouped"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "服装\n",
      "           日期   名称  类别   单价  数量    金额\n",
      "0  2018-07-01  商品A  服装   20   2    40\n",
      "1  2018-07-02  商品B  服装  200   3   600\n",
      "3  2018-07-04  商品A  服装   22   5   110\n",
      "4  2018-07-05  商品B  服装  220   6  1320\n",
      "6  2018-07-07  商品A  服装   30   3    90\n",
      "7  2018-07-08  商品A  服装  800   1   800\n",
      "9  2018-07-10  商品B  服装  230   3   690\n",
      "10 2018-07-11  商品A  服装   28   1    28\n",
      "食品\n",
      "          日期   名称  类别    单价  数量    金额\n",
      "2 2018-07-03  商品C  食品  1200   4  4800\n",
      "5 2018-07-06  商品C  食品  1000   7  7000\n",
      "8 2018-07-09  商品C  食品  1300   4  5200\n"
     ]
    }
   ],
   "source": [
    "for name,data in grouped:\n",
    "    print(name)\n",
    "    print(data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>数量</th>\n",
       "      <th>金额</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>类别</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>服装</th>\n",
       "      <td>24</td>\n",
       "      <td>3678</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>食品</th>\n",
       "      <td>15</td>\n",
       "      <td>17000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    数量     金额\n",
       "类别           \n",
       "服装  24   3678\n",
       "食品  15  17000"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grouped['数量','金额'].sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "类别\n",
       "服装     800\n",
       "食品    1300\n",
       "Name: 单价, dtype: int64"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grouped['单价'].max()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "类别  名称 \n",
       "服装  商品A     800\n",
       "    商品B     230\n",
       "食品  商品C    1300\n",
       "Name: 单价, dtype: int64"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grouped2 = df.groupby(['类别','名称'])\n",
    "grouped2['单价'].max()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>单价</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>类别</th>\n",
       "      <th>名称</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">服装</th>\n",
       "      <th>商品A</th>\n",
       "      <td>180.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>商品B</th>\n",
       "      <td>216.666667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>食品</th>\n",
       "      <th>商品C</th>\n",
       "      <td>1166.666667</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                 单价\n",
       "类别 名称              \n",
       "服装 商品A   180.000000\n",
       "   商品B   216.666667\n",
       "食品 商品C  1166.666667"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grouped2[['单价']].mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "服装\n",
      "0     商品A\n",
      "1     商品B\n",
      "3     商品A\n",
      "4     商品B\n",
      "6     商品A\n",
      "7     商品A\n",
      "9     商品B\n",
      "10    商品A\n",
      "Name: 名称, dtype: object\n",
      "食品\n",
      "2    商品C\n",
      "5    商品C\n",
      "8    商品C\n",
      "Name: 名称, dtype: object\n"
     ]
    }
   ],
   "source": [
    "for name,data in grouped:\n",
    "    print(name)\n",
    "    print(data['名称'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "服装\n",
      "['商品A' '商品B']\n",
      "食品\n",
      "['商品C']\n"
     ]
    }
   ],
   "source": [
    "for name,data in grouped:\n",
    "    print(name)\n",
    "    print(data['名称'].unique())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "('服装', '商品A')\n",
      "['商品A']\n",
      "('服装', '商品B')\n",
      "['商品B']\n",
      "('食品', '商品C')\n",
      "['商品C']\n"
     ]
    }
   ],
   "source": [
    "for name,data in grouped2:\n",
    "    print(name)\n",
    "    print(data['名称'].unique())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1580033625.0905402"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import time\n",
    "time.time()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2020-01-26 18:13:45'"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2018, tm_mon=7, tm_mday=4, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=2, tm_yday=185, tm_isdst=-1)"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.strptime('2018-07-04', '%Y-%m-%d')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.datetime(2020, 1, 26, 18, 13, 45, 137302)"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from datetime import datetime\n",
    "datetime.now()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2020-01-26 18:13:45'"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.now().strftime('%Y-%m-%d %H:%M:%S')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.datetime(2018, 7, 4, 0, 0)"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.strptime('2018-07-04', '%Y-%m-%d')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1580033625.190183"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.now().timestamp()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "571"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "delta = datetime.now() -datetime.strptime('2018-07-04', '%Y-%m-%d')\n",
    "delta.days "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2018-05-06', '2018-05-13', '2018-05-20', '2018-05-27',\n",
       "               '2018-06-03', '2018-06-10', '2018-06-17', '2018-06-24',\n",
       "               '2018-07-01', '2018-07-08', '2018-07-15', '2018-07-22',\n",
       "               '2018-07-29', '2018-08-05', '2018-08-12', '2018-08-19',\n",
       "               '2018-08-26', '2018-09-02', '2018-09-09', '2018-09-16',\n",
       "               '2018-09-23', '2018-09-30'],\n",
       "              dtype='datetime64[ns]', freq='W-SUN')"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# init time series \n",
    "pd.date_range('2018-5-1','2018-10-1',freq = 'W')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2018-06-30', '2018-09-30', '2018-12-31', '2019-03-31',\n",
       "               '2019-06-30', '2019-09-30', '2019-12-31', '2020-03-31',\n",
       "               '2020-06-30', '2020-09-30'],\n",
       "              dtype='datetime64[ns]', freq='Q-DEC')"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.date_range('2018-5-1',freq = 'Q',periods=10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "data= {\n",
    "    'time':pd.date_range('2020-1-26', periods=20000, freq = 'T'),\n",
    "    'cpu' :np.random.randn(20000) + 10\n",
    "}\n",
    "df = pd.DataFrame(data, columns=['time', 'cpu'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>time</th>\n",
       "      <th>cpu</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2020-01-26 00:00:00</td>\n",
       "      <td>8.312269</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2020-01-26 00:01:00</td>\n",
       "      <td>11.919169</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2020-01-26 00:02:00</td>\n",
       "      <td>10.712443</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2020-01-26 00:03:00</td>\n",
       "      <td>10.219426</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2020-01-26 00:04:00</td>\n",
       "      <td>9.167475</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                 time        cpu\n",
       "0 2020-01-26 00:00:00   8.312269\n",
       "1 2020-01-26 00:01:00  11.919169\n",
       "2 2020-01-26 00:02:00  10.712443\n",
       "3 2020-01-26 00:03:00  10.219426\n",
       "4 2020-01-26 00:04:00   9.167475"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 20000 entries, 0 to 19999\n",
      "Data columns (total 2 columns):\n",
      "time    20000 non-null datetime64[ns]\n",
      "cpu     20000 non-null float64\n",
      "dtypes: datetime64[ns](1), float64(1)\n",
      "memory usage: 312.6 KB\n"
     ]
    }
   ],
   "source": [
    "df.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>time</th>\n",
       "      <th>cpu</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2020-01-26 00:02:00</td>\n",
       "      <td>10.712443</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2020-01-26 00:03:00</td>\n",
       "      <td>10.219426</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2020-01-26 00:04:00</td>\n",
       "      <td>9.167475</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2020-01-26 00:05:00</td>\n",
       "      <td>9.910272</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2020-01-26 00:06:00</td>\n",
       "      <td>8.715915</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2020-01-26 00:07:00</td>\n",
       "      <td>10.948947</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>2020-01-26 00:08:00</td>\n",
       "      <td>10.352613</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2020-01-26 00:09:00</td>\n",
       "      <td>8.476890</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>2020-01-26 00:10:00</td>\n",
       "      <td>11.198877</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>2020-01-26 00:11:00</td>\n",
       "      <td>11.402555</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>2020-01-26 00:12:00</td>\n",
       "      <td>7.776856</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                  time        cpu\n",
       "2  2020-01-26 00:02:00  10.712443\n",
       "3  2020-01-26 00:03:00  10.219426\n",
       "4  2020-01-26 00:04:00   9.167475\n",
       "5  2020-01-26 00:05:00   9.910272\n",
       "6  2020-01-26 00:06:00   8.715915\n",
       "7  2020-01-26 00:07:00  10.948947\n",
       "8  2020-01-26 00:08:00  10.352613\n",
       "9  2020-01-26 00:09:00   8.476890\n",
       "10 2020-01-26 00:10:00  11.198877\n",
       "11 2020-01-26 00:11:00  11.402555\n",
       "12 2020-01-26 00:12:00   7.776856"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[(df.time >= '2020-01-26 00:02:00') & (df.time <= '2020-01-26 00:12:00')]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>time</th>\n",
       "      <th>cpu</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>time</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2020-01-26 00:00:00</th>\n",
       "      <td>2020-01-26 00:00:00</td>\n",
       "      <td>8.312269</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-26 00:01:00</th>\n",
       "      <td>2020-01-26 00:01:00</td>\n",
       "      <td>11.919169</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-26 00:02:00</th>\n",
       "      <td>2020-01-26 00:02:00</td>\n",
       "      <td>10.712443</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-26 00:03:00</th>\n",
       "      <td>2020-01-26 00:03:00</td>\n",
       "      <td>10.219426</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-26 00:04:00</th>\n",
       "      <td>2020-01-26 00:04:00</td>\n",
       "      <td>9.167475</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                   time        cpu\n",
       "time                                              \n",
       "2020-01-26 00:00:00 2020-01-26 00:00:00   8.312269\n",
       "2020-01-26 00:01:00 2020-01-26 00:01:00  11.919169\n",
       "2020-01-26 00:02:00 2020-01-26 00:02:00  10.712443\n",
       "2020-01-26 00:03:00 2020-01-26 00:03:00  10.219426\n",
       "2020-01-26 00:04:00 2020-01-26 00:04:00   9.167475"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.index = pd.to_datetime(df.time)\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>cpu</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>time</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2020-01-26 00:00:00</th>\n",
       "      <td>8.312269</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-26 00:01:00</th>\n",
       "      <td>11.919169</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-26 00:02:00</th>\n",
       "      <td>10.712443</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-26 00:03:00</th>\n",
       "      <td>10.219426</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-26 00:04:00</th>\n",
       "      <td>9.167475</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-02-08 21:15:00</th>\n",
       "      <td>10.394474</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-02-08 21:16:00</th>\n",
       "      <td>10.421313</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-02-08 21:17:00</th>\n",
       "      <td>11.098638</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-02-08 21:18:00</th>\n",
       "      <td>11.097320</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-02-08 21:19:00</th>\n",
       "      <td>9.990885</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>20000 rows × 1 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                           cpu\n",
       "time                          \n",
       "2020-01-26 00:00:00   8.312269\n",
       "2020-01-26 00:01:00  11.919169\n",
       "2020-01-26 00:02:00  10.712443\n",
       "2020-01-26 00:03:00  10.219426\n",
       "2020-01-26 00:04:00   9.167475\n",
       "...                        ...\n",
       "2020-02-08 21:15:00  10.394474\n",
       "2020-02-08 21:16:00  10.421313\n",
       "2020-02-08 21:17:00  11.098638\n",
       "2020-02-08 21:18:00  11.097320\n",
       "2020-02-08 21:19:00   9.990885\n",
       "\n",
       "[20000 rows x 1 columns]"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.drop('time',axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>time</th>\n",
       "      <th>cpu</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>time</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2020-01-26 00:00:00</th>\n",
       "      <td>2020-01-26 00:00:00</td>\n",
       "      <td>8.312269</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-26 00:01:00</th>\n",
       "      <td>2020-01-26 00:01:00</td>\n",
       "      <td>11.919169</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-26 00:02:00</th>\n",
       "      <td>2020-01-26 00:02:00</td>\n",
       "      <td>10.712443</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-26 00:03:00</th>\n",
       "      <td>2020-01-26 00:03:00</td>\n",
       "      <td>10.219426</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-26 00:04:00</th>\n",
       "      <td>2020-01-26 00:04:00</td>\n",
       "      <td>9.167475</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-26 00:05:00</th>\n",
       "      <td>2020-01-26 00:05:00</td>\n",
       "      <td>9.910272</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-26 00:06:00</th>\n",
       "      <td>2020-01-26 00:06:00</td>\n",
       "      <td>8.715915</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-26 00:07:00</th>\n",
       "      <td>2020-01-26 00:07:00</td>\n",
       "      <td>10.948947</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-26 00:08:00</th>\n",
       "      <td>2020-01-26 00:08:00</td>\n",
       "      <td>10.352613</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-26 00:09:00</th>\n",
       "      <td>2020-01-26 00:09:00</td>\n",
       "      <td>8.476890</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-26 00:10:00</th>\n",
       "      <td>2020-01-26 00:10:00</td>\n",
       "      <td>11.198877</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                   time        cpu\n",
       "time                                              \n",
       "2020-01-26 00:00:00 2020-01-26 00:00:00   8.312269\n",
       "2020-01-26 00:01:00 2020-01-26 00:01:00  11.919169\n",
       "2020-01-26 00:02:00 2020-01-26 00:02:00  10.712443\n",
       "2020-01-26 00:03:00 2020-01-26 00:03:00  10.219426\n",
       "2020-01-26 00:04:00 2020-01-26 00:04:00   9.167475\n",
       "2020-01-26 00:05:00 2020-01-26 00:05:00   9.910272\n",
       "2020-01-26 00:06:00 2020-01-26 00:06:00   8.715915\n",
       "2020-01-26 00:07:00 2020-01-26 00:07:00  10.948947\n",
       "2020-01-26 00:08:00 2020-01-26 00:08:00  10.352613\n",
       "2020-01-26 00:09:00 2020-01-26 00:09:00   8.476890\n",
       "2020-01-26 00:10:00 2020-01-26 00:10:00  11.198877"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['2020-01-26 00:00:00' : '2020-01-26 00:10:00']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>time</th>\n",
       "      <th>cpu</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>time</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2020-01-26 00:00:00</th>\n",
       "      <td>2020-01-26 00:00:00</td>\n",
       "      <td>8.312269</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-26 00:01:00</th>\n",
       "      <td>2020-01-26 00:01:00</td>\n",
       "      <td>11.919169</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-26 00:02:00</th>\n",
       "      <td>2020-01-26 00:02:00</td>\n",
       "      <td>10.712443</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-26 00:03:00</th>\n",
       "      <td>2020-01-26 00:03:00</td>\n",
       "      <td>10.219426</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-26 00:04:00</th>\n",
       "      <td>2020-01-26 00:04:00</td>\n",
       "      <td>9.167475</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-26 23:55:00</th>\n",
       "      <td>2020-01-26 23:55:00</td>\n",
       "      <td>10.100305</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-26 23:56:00</th>\n",
       "      <td>2020-01-26 23:56:00</td>\n",
       "      <td>11.644511</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-26 23:57:00</th>\n",
       "      <td>2020-01-26 23:57:00</td>\n",
       "      <td>9.348114</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-26 23:58:00</th>\n",
       "      <td>2020-01-26 23:58:00</td>\n",
       "      <td>9.477132</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-26 23:59:00</th>\n",
       "      <td>2020-01-26 23:59:00</td>\n",
       "      <td>8.813265</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1440 rows × 2 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                   time        cpu\n",
       "time                                              \n",
       "2020-01-26 00:00:00 2020-01-26 00:00:00   8.312269\n",
       "2020-01-26 00:01:00 2020-01-26 00:01:00  11.919169\n",
       "2020-01-26 00:02:00 2020-01-26 00:02:00  10.712443\n",
       "2020-01-26 00:03:00 2020-01-26 00:03:00  10.219426\n",
       "2020-01-26 00:04:00 2020-01-26 00:04:00   9.167475\n",
       "...                                 ...        ...\n",
       "2020-01-26 23:55:00 2020-01-26 23:55:00  10.100305\n",
       "2020-01-26 23:56:00 2020-01-26 23:56:00  11.644511\n",
       "2020-01-26 23:57:00 2020-01-26 23:57:00   9.348114\n",
       "2020-01-26 23:58:00 2020-01-26 23:58:00   9.477132\n",
       "2020-01-26 23:59:00 2020-01-26 23:59:00   8.813265\n",
       "\n",
       "[1440 rows x 2 columns]"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['2020-01-26']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>cpu</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2020-01-26</th>\n",
       "      <td>9.968794</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-27</th>\n",
       "      <td>10.017980</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-28</th>\n",
       "      <td>9.951939</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-29</th>\n",
       "      <td>10.009008</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-30</th>\n",
       "      <td>9.963753</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-31</th>\n",
       "      <td>9.984021</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-02-01</th>\n",
       "      <td>10.001928</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-02-02</th>\n",
       "      <td>10.017549</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-02-03</th>\n",
       "      <td>10.022772</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-02-04</th>\n",
       "      <td>9.989082</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-02-05</th>\n",
       "      <td>10.009158</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-02-06</th>\n",
       "      <td>10.016073</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-02-07</th>\n",
       "      <td>9.977333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-02-08</th>\n",
       "      <td>10.071260</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                  cpu\n",
       "2020-01-26   9.968794\n",
       "2020-01-27  10.017980\n",
       "2020-01-28   9.951939\n",
       "2020-01-29  10.009008\n",
       "2020-01-30   9.963753\n",
       "2020-01-31   9.984021\n",
       "2020-02-01  10.001928\n",
       "2020-02-02  10.017549\n",
       "2020-02-03  10.022772\n",
       "2020-02-04   9.989082\n",
       "2020-02-05  10.009158\n",
       "2020-02-06  10.016073\n",
       "2020-02-07   9.977333\n",
       "2020-02-08  10.071260"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.groupby(df.index.date).mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>cpu</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>time</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10.037333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>9.990189</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>10.007234</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>10.005895</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>10.033120</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>9.953709</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>10.020283</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>9.999730</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>10.008361</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>10.052366</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>10.021373</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>10.018616</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>10.004147</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>9.973741</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>9.996302</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>10.004449</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>9.964360</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>9.989181</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>9.971162</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>9.958779</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>10.020816</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>9.952936</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>9.996017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>10.005297</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            cpu\n",
       "time           \n",
       "0     10.037333\n",
       "1      9.990189\n",
       "2     10.007234\n",
       "3     10.005895\n",
       "4     10.033120\n",
       "5      9.953709\n",
       "6     10.020283\n",
       "7      9.999730\n",
       "8     10.008361\n",
       "9     10.052366\n",
       "10    10.021373\n",
       "11    10.018616\n",
       "12    10.004147\n",
       "13     9.973741\n",
       "14     9.996302\n",
       "15    10.004449\n",
       "16     9.964360\n",
       "17     9.989181\n",
       "18     9.971162\n",
       "19     9.958779\n",
       "20    10.020816\n",
       "21     9.952936\n",
       "22     9.996017\n",
       "23    10.005297"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.groupby(df.index.hour).mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>cpu</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>time</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>9.968794</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>9.992311</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>10.013205</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            cpu\n",
       "time           \n",
       "4      9.968794\n",
       "5      9.992311\n",
       "6     10.013205"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.groupby(df.index.week).mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>cpu</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>time</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2020-01-26 00:00:00</th>\n",
       "      <td>10.066156</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-26 00:05:00</th>\n",
       "      <td>9.680927</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-26 00:10:00</th>\n",
       "      <td>10.102425</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-26 00:15:00</th>\n",
       "      <td>10.033853</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-26 00:20:00</th>\n",
       "      <td>9.693576</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-02-08 20:55:00</th>\n",
       "      <td>10.606647</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-02-08 21:00:00</th>\n",
       "      <td>9.942282</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-02-08 21:05:00</th>\n",
       "      <td>9.788180</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-02-08 21:10:00</th>\n",
       "      <td>9.627183</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-02-08 21:15:00</th>\n",
       "      <td>10.600526</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>4000 rows × 1 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                           cpu\n",
       "time                          \n",
       "2020-01-26 00:00:00  10.066156\n",
       "2020-01-26 00:05:00   9.680927\n",
       "2020-01-26 00:10:00  10.102425\n",
       "2020-01-26 00:15:00  10.033853\n",
       "2020-01-26 00:20:00   9.693576\n",
       "...                        ...\n",
       "2020-02-08 20:55:00  10.606647\n",
       "2020-02-08 21:00:00   9.942282\n",
       "2020-02-08 21:05:00   9.788180\n",
       "2020-02-08 21:10:00   9.627183\n",
       "2020-02-08 21:15:00  10.600526\n",
       "\n",
       "[4000 rows x 1 columns]"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.resample('5T').mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
